﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MobileWeb.Helpers;
using MobileWeb.Models;

namespace MobileWeb.Controllers
{
    public class StanoviController : Controller
    {
        //
        // GET: /Stanovi/
        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /OProjektu/
        public ActionResult OProjektu()
        {
            return View();
        }

        //
        // GET: /Opis/
        public ActionResult Opis()
        {
            return View();
        }

        //
        // GET: /Kontakt/
        public ActionResult Kontakt()
        {
            return View();
        }

        //
        // GET: /Pregled/
        public ActionResult Pregled()
        {
            var model = new SearchModel()
            {
                Areas = IntervalHelper.GetAreas(),
                Floors = IntervalHelper.GetFloors(),
                NumOfRooms = IntervalHelper.GetNumOfRooms(),
                Prices = IntervalHelper.GetPrices(),
                Apartments = SearchHelper.GetApartments("8", "20", "1", "52"),
            };
            
            return View(model);
        }

        //
        // POST : /Pregled/ 
        [HttpPost]
        public ActionResult Pregled(SearchModel searchModel)
        {
            var selectedArea = searchModel.SelectedArea.ToString();
            var selectedFloor = searchModel.SelectedFloor.ToString();
            var selectedNumOfRooms = searchModel.SelectedNumOfRooms.ToString();
            var selectedPrice = searchModel.SelectedPrice.ToString();

            var model = new SearchModel()
            {
                Areas = IntervalHelper.GetAreas(),
                Floors = IntervalHelper.GetFloors(),
                NumOfRooms = IntervalHelper.GetNumOfRooms(),
                Prices = IntervalHelper.GetPrices(),
                Apartments = SearchHelper.GetApartments(selectedFloor, selectedNumOfRooms, selectedArea, selectedPrice)
            };

            searchModel = model;
            return View(searchModel);
        }

        //
        // GET: /RabatnaSkala/
        public ActionResult RabatnaSkala()
        {
            return View();
        }

        //
        // GET: /Kreditiranje/
        public ActionResult Kreditiranje()
        {
            return View();
        }

        //
        // GET: /Karakteristicni/
        public ActionResult Karakteristicni()
        {
            return View();
        }

        //
        // GET: /Detalji/
        public ActionResult Detalji(int id)
        {
            var apartment = SearchHelper.GetApartment(id);
            return View(apartment);
        }
    }
}
